'''

    SHT - Sys Hot Typper
    
    This shell app remaps the system keyboard event 
    using the HotTypper KeyGen.

'''

import sys, os, time

shikPath = os.path.abspath('../../../')
if shikPath not in sys.path:
    sys.path.append(shikPath)

import SHIK.devices

def print_event(device, func_name):
    print device, func_name
    
def main():
    print "Initializing SysHotTyper:"
    
    print "  Keyboard"
    keyboard = SHIK.devices.SysKeyboard()
    #keyboard.DEBUG(True)
    
    print "  KeyGen"
    hottyper = SHIK.keygens.HotTyper()

    print "  KeyMaps"
    KC = SHIK.devices.KeyControl
    keymaps = {
        'AZERTY': (
             KC("S"),
             KC("D"),
             KC("F"),
             KC("Z"),
             KC("E"),
             KC("R"),
             KC("Space"),
        ),
        'AZERTY angle': (
             KC("D"),
             KC("F"),
             KC("V"),
             KC("R"),
             KC("T"),
             KC("G"),
             KC("Space"),
        ),
        'QWERTY': (
             KC("A"),
             KC("S"),
             KC("D"),
             KC("Q"),
             KC("W"),
             KC("E"),
             KC("Space"),
        ),
        'NumPad 90cw': (
             KC("Down"),
             KC("Clear"),
             KC("Up"),
             KC("End"),
             KC("Left"),
             KC("Home"),
             KC("Back"),
        ),
    }

    print "  Binding all"
    keymap_name = 'AZERTY'
#    keymap_name = 'NumPad 90cw'
    keyboard.add_keygen(hottyper, keymaps[keymap_name])
#    keyboard.add_listener(print_event)
    
    print "Ready."
    while 1:
        time.sleep(1)
        
if __name__ == "__main__":
    main()